<template>
	<u-image :width="wrapSize" :height="wrapSize" :src="imgUrl" shape="circle">
		<u-image  slot="error" :width="wrapSize" :height="wrapSize" :src="formatSrc()"></u-image>
	</u-image>
</template>

<script>
	export default {
		name:"ChildrenHeadView",
		props: {
			imgUrl: {
				type: String,
				default () {
					return ''
				}
			},
			gender: {
				type: [String, Number],
				default () {
					return 0
				}
			},
			gray: {
				type: Boolean,
				default () {
					return false
				}
			},
			// 尺寸，default，medium，mini
			size: {
				type: String,
				default () {
					return 'default';
				} 
			},
			isParent: {
				type: Boolean,
				default () {
					return false;
				}
			}
		},
		computed: {
			wrapSize() {
				if (this.size === 'mini') {
					return '60rpx';
				} else if (this.size === 'medium') {
					return '90rpx';
				} else if (this.size === 'big') {
					return '150rpx';
				}
				return '120rpx';
			}
		},
		data() {
			return {
				
			};
		},
		methods: {
			formatSrc() {
				if (this.isParent) {
					if (this.gray) {
						return 'https://dotflat-saas-res.oss-cn-shanghai.aliyuncs.com/xybaby365/app/icons/icon_photo_teacher.png'
					} else {
						return 'https://dotflat-saas-res.oss-cn-shanghai.aliyuncs.com/xybaby365/app/icons/icon_photo_teacher.png'
					}
				}
				
				if (this.gray) {
					if (parseInt(this.gender) === 0) {
						return 'https://dotflat-saas-res.oss-cn-shanghai.aliyuncs.com/xybaby365/app/icons/icon_photo_female_gray.png';
					} else {
						return 'https://dotflat-saas-res.oss-cn-shanghai.aliyuncs.com/xybaby365/app/icons/icon_photo_male_gray.png';
					}
				} else {
					if (parseInt(this.gender) === 0) {
						return 'https://dotflat-saas-res.oss-cn-shanghai.aliyuncs.com/xybaby365/app/icons/icon_photo_female.png';
					} else {
						return 'https://dotflat-saas-res.oss-cn-shanghai.aliyuncs.com/xybaby365/app/icons/icon_photo_male.png';
					}
				}
			},
		}
	}
</script>

<style>

</style>
